package com.sky.mapper;

import com.sky.entity.ShoppingCart;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.web.bind.annotation.DeleteMapping;

import java.util.List;

@Mapper
public interface ShoppingCartMapper {

    /**
     * 查询用户
     * @return
     */
    @Select("select * from sky_take_out.shopping_cart")
    List<ShoppingCart> list();

    /**
     * 查询购物车商品
     * @param shoppingCart
     * @return
     */
    ShoppingCart getByUserIdAndDishIdOrSetmealId(ShoppingCart shoppingCart);

    /**
     * 根据购物车id修改购物车
     * @param shoppingCartId
     */
    void updateByShoppingCartId(Long shoppingCartId);

    /**
     * 插入数据库
     * @param shoppingCart
     */
    void insert(ShoppingCart shoppingCart);

    /**
     * 删除购物车
     * @param userId
     */
    @Delete("delete from sky_take_out.shopping_cart where user_id=#{userId}")
    void deleteByUserId(Long userId);
}
